package cn.ming.leo.resource.manager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import cn.ming.leo.bean.Box;
import cn.ming.leo.bean.vo.RequestJson;
import cn.ming.leo.service.BoxService;
import cn.ming.leo.utils.Message;
import cn.ming.leo.utils.PageListModel;

@RestController
@RequestMapping("/m/box")
public class MBoxResource {

	@Autowired
	private BoxService boxService;

	/*** 1.1.1 ****/

	@RequestMapping(value = "/view", method = RequestMethod.GET)
	public Message<Box> getById(int id) {
		return boxService.getById(id);
	}

	@RequestMapping(value = "/findAll", method = RequestMethod.GET)
	public Message<PageListModel<Box>> findAll(Integer pageIndex, Integer pageSize) {
		return boxService.findAll(pageIndex, pageSize);
	}

	/*** 1.1.1 ****/

	@RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
	@ResponseBody
	public Message<String> remove(@RequestBody RequestJson json) {
		return boxService.updateStatus(json.getId(), json.getStatus());
	}

}
